//力扣622设计循环队列
class MyCircularQueue {
    private int []arr;
    private int front;
    private int rear;
    private int size;
    public MyCircularQueue(int k) {
        size = k+1;
        arr = new int[size];
        front = rear = 0;
    }
    
    public boolean enQueue(int value) {
        if(isFull()){
            return false;
        }else{
            arr[rear] = value;
            rear = (rear + 1) % size;
            return true;
        }
    }
    
    public boolean deQueue() {
        if(isEmpty()){
            return false;
        }else{
            front = (front + 1) % size;
            return true;
        }
    }
    
    public int Front() {
        if(isEmpty()){
            return -1;
        }else{
            return arr[front];
        }
    }
    
    public int Rear() {
         if(isEmpty()){
            return -1;
        }else{
            if(rear == 0){
                return arr[size - 1];
            }else{
                return arr[rear - 1];
            }                    
        }
    }
    
    public boolean isEmpty() {
        return rear == front;
    }
    
    public boolean isFull() {
        return front == (rear+1) % size;
    }
}